package com.wechat.mp.common;

import com.alibaba.fastjson.JSONObject;

public class RetEntry {
    //成功返回码
    public static final String CODE_SUCC = "0";
    //错误返回码
    public static final String CODE_ERROR = "1";

    private String retCode;
    private String retMsg;
    private JSONObject data = new JSONObject();

    public RetEntry(){}

    public RetEntry(String retCode, String retMsg) {
        this.retCode = retCode;
        this.retMsg = retMsg;
    }

    public String getRetCode() {
        return retCode;
    }

    public void setRetCode(String retCode) {
        this.retCode = retCode;
    }

    public String getRetMsg() {
        return retMsg;
    }

    public void setRetMsg(String retMsg) {
        this.retMsg = retMsg;
    }

    public JSONObject getData() {
        return data;
    }

    public void setData(JSONObject data) {
        this.data = data;
    }

    public RetEntry setSuccMsg(String succMsg){
        this.retCode = RetEntry.CODE_SUCC;
        this.retMsg = succMsg;
        return this;
    }

    public RetEntry setErrorMsg(String errorMsg){
        this.retCode = RetEntry.CODE_ERROR;
        this.retMsg = errorMsg;
        return this;
    }

    public RetEntry addData(String key,Object data){
        this.data.put(key,data);
        return this;
    }

    public static RetEntry errorRetEntry(String errorMsg){
        RetEntry r = new RetEntry();
        r.setErrorMsg(errorMsg);
        return r;
    }

    public static RetEntry succRetEntry(String succMsg){
        RetEntry r = new RetEntry();
        r.setSuccMsg(succMsg);
        return r;
    }
}
